home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 2
/
Atari Mega Archive CD - Volume 2.iso
/
linux
/
tools
/
gtar10.lha
/
getdate.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-09
|
45KB
|
1,775 lines
/* A Bison parser, made from getdate.y */
#define YYBISON 1 /* Identify Bison output. */
#define tAGO 258
#define tDAY 259
#define tDAYZONE 260
#define tID 261
#define tMERIDIAN 262
#define tMINUTE_UNIT 263
#define tMONTH 264
#define tMONTH_UNIT 265
#define tSEC_UNIT 266
#define tSNUMBER 267
#define tUNUMBER 268
#define tZONE 269
#line 1 "getdate.y"
/* $Revision: 2.1 $
**
** Originally written by Steven M. Bellovin <smb@research.att.com> while
** at the University of North Carolina at Chapel Hill. Later tweaked by
** a couple of people on Usenet. Completely overhauled by Rich $alz
** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990;
** send any email to Rich.
**
** This grammar has eight shift/reduce conflicts.
**
** This code is in the public domain and has no copyright.
*/
/* SUPPRESS 287 on yaccpar_sccsid *//* Unusd static variable */
/* SUPPRESS 288 on yyerrlab *//* Label unused */
#ifdef __GNUC__
#define alloca __builtin_alloca
#else
#ifdef sparc
#include <alloca.h>
#else
#ifdef _AIX /* for Bison */
#pragma alloca
#else
char *alloca ();
#endif
#endif
#endif
#include <stdio.h>
#include <ctype.h>
#if defined(vms)
#include <types.h>
#include <time.h>
#else
#include <sys/types.h>
#if defined(USG)
/*
** Uncomment the next line if you need to do a tzset() call to set the
** timezone, and don't have ftime(). Some SystemV releases, I think.
*/
/*#define NEED_TZSET */
struct timeb {
time_t time; /* Seconds since the epoch */
unsigned short millitm; /* Field not used */
short timezone;
short dstflag; /* Field not used */
};
#else
#include <sys/timeb.h>
#endif /* defined(USG) */
#if defined(BSD4_2) || defined(BSD4_1C)
#include <sys/time.h>
#else
#include <time.h>
#endif /* defined(BSD4_2) */
#endif /* defined(vms) */
#if defined (STDC_HEADERS) || defined (USG)
#include <string.h>
#endif
extern struct tm *localtime();
#define yyparse getdate_yyparse
#define yylex getdate_yylex
#define yyerror getdate_yyerror
#if !defined(lint) && !defined(SABER)
static char RCS[] =
"$Header: str2date.y,v 2.1 90/09/06 08:15:06 cronan Exp $";
#endif /* !defined(lint) && !defined(SABER) */
#define EPOCH 1970
#define HOUR(x) (x * 60)
#define SECSPERDAY (24L * 60L * 60L)
/*
** An entry in the lexical lookup table.
*/
typedef struct _TABLE {
char *name;
int type;
time_t value;
} TABLE;
/*
** Daylight-savings mode: on, off, or not yet known.
*/
typedef enum _DSTMODE {
DSTon, DSToff, DSTmaybe
} DSTMODE;
/*
** Meridian: am, pm, or 24-hour style.
*/
typedef enum _MERIDIAN {
MERam, MERpm, MER24
} MERIDIAN;
/*
** Global variables. We could get rid of most of these by using a good
** union as the yacc stack. (This routine was originally written before
** yacc had the %union construct.) Maybe someday; right now we only use
** the %union very rarely.
*/
static char *yyInput;
static DSTMODE yyDSTmode;
static time_t yyDayOrdinal;
static time_t yyDayNumber;
static int yyHaveDate;
static int yyHaveDay;
static int yyHaveRel;
static int yyHaveTime;
static int yyHaveZone;
static time_t yyTimezone;
static time_t yyDay;
static time_t yyHour;
static time_t yyMinutes;
static time_t yyMonth;
static time_t yySeconds;
static time_t yyYear;
static MERIDIAN yyMeridian;
static time_t yyRelMonth;
static time_t yyRelSeconds;
#line 135 "getdate.y"
typedef union {
time_t Number;
enum _MERIDIAN Meridian;
} YYSTYPE;
#ifndef YYLTYPE
typedef
struct yyltype
{
int timestamp;
int first_line;
int first_column;
int last_line;
int last_column;
char *text;
}
yyltype;
#define YYLTYPE yyltype
#endif
#include <stdio.h>
#ifndef __STDC__
#define const
#endif
#define YYFINAL 48
#define YYFLAG -32768
#define YYNTBASE 18
#define YYTRANSLATE(x) ((unsigned)(x) <= 269 ? yytranslate[x] : 28)
static const char yytranslate[] = { 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 16, 2, 2, 17, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 15, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
6, 7, 8, 9, 10, 11, 12, 13, 14
};
#if YYDEBUG != 0
static const short yyprhs[] = { 0,
0, 1, 4, 6, 8, 10, 12, 14, 16, 19,
24, 29, 36, 43, 45, 47, 49, 52, 55, 59,
65, 68, 73, 76, 80, 83, 85, 88, 91, 93,
96, 99, 101, 104, 107, 109, 111, 112
};
#endif
static const short yyrhs[] = { -1,
18, 19, 0, 20, 0, 21, 0, 23, 0, 22,
0, 24, 0, 26, 0, 13, 7, 0, 13, 15,
13, 27, 0, 13, 15, 13, 12, 0, 13, 15,
13, 15, 13, 27, 0, 13, 15, 13, 15, 13,
12, 0, 14, 0, 5, 0, 4, 0, 4, 16,
0, 13, 4, 0, 13, 17, 13, 0, 13, 17,
13, 17, 13, 0, 9, 13, 0, 9, 13, 16,
13, 0, 13, 9, 0, 13, 9, 13, 0, 25,
3, 0, 25, 0, 13, 8, 0, 12, 8, 0,
8, 0, 12, 11, 0, 13, 11, 0, 11, 0,
12, 10, 0, 13, 10, 0, 10, 0, 13, 0,
0, 7, 0
};
#if YYDEBUG != 0
static const short yyrline[] = { 0,
149, 150, 153, 156, 159, 162, 165, 168, 171, 177,
183, 190, 196, 206, 210, 216, 220, 224, 230, 234,
239, 243, 248, 252, 259, 263, 266, 269, 272, 275,
278, 281, 284, 287, 290, 295, 323, 326
};
static const char * const yytname[] = { "$","error","$illegal.","tAGO","tDAY",
"tDAYZONE","tID","tMERIDIAN","tMINUTE_UNIT","tMONTH","tMONTH_UNIT","tSEC_UNIT",
"tSNUMBER","tUNUMBER","tZONE","':'","','","'/'","spec","item","time","zone",
"day","date","rel","relunit","number","o_merid",""
};
#endif
static const short yyr1[] = { 0,
18, 18, 19, 19, 19, 19, 19, 19, 20, 20,
20, 20, 20, 21, 21, 22, 22, 22, 23, 23,
23, 23, 23, 23, 24, 24, 25, 25, 25, 25,
25, 25, 25, 25, 25, 26, 27, 27
};
static const short yyr2[] = { 0,
0, 2, 1, 1, 1, 1, 1, 1, 2, 4,
4, 6, 6, 1, 1, 1, 2, 2, 3, 5,
2, 4, 2, 3, 2, 1, 2, 2, 1, 2,
2,